home *** CD-ROM | disk | FTP | other *** search
Korn shell script | 2000-05-20 | 5.9 KB | 227 lines |
- #! /bin/ksh -p
- #
- # @(#)java_wrapper.sh 1.35 98/12/23
- #
- #===================================================================
- # THIS SCRIPT AND JAVA WILL NOT RUN UNDER SUNOS4.X, AKA SOLARIS 1.X.
- #===================================================================
-
- set +u
-
- function path_warn {
- echo "Warning -- $2 not consistent with the Java home location."
- echo $2 is: $1
- echo JAVA_HOME is: $JAVA_HOME
- if [[ $2 = CLASSPATH ]]
- then
- echo "We recommend not putting any system classes into CLASSPATH."
- echo "(The java invocation script will add these in the correct place.)"
- else
- if [[ $2 = LD_LIBRARY_PATH ]]
- then
- echo "We recommend not putting any system libraries into LD_LIBRARY_PATH."
- echo "(The java invocation script will add these in the correct place.)"
- else
- if [[ $2 = LD_LIBRARYN32_PATH ]]
- then
- echo "We recommend not putting any system libraries into LD_LIBRARYN32_PATH."
- echo "(The java invocation script will add these in the correct place.)"
- fi
- fi
- fi
- }
-
- function check_path {
- if egrep -s '^/usr/java/|:/usr/java/' << EOF
- $1
- EOF
- then
- if ! egrep -s '^/usr/java$|^/usr/java/' << EOF
- $JAVA_HOME
- EOF
- then
- # CLASSPATH/LD_LIBRARY_PATH/LD_LIBRARYN32_PATH
- # has components from /usr/java, but
- # java components are not being taken from /usr/java.
- path_warn $1 $2
- fi
- else
- if egrep -s /usr/java/ << EOF
- $1
- EOF
- then
- if egrep -s '^/usr/java$|^/usr/java/' << EOF
- $JAVA_HOME
- EOF
- then
- # CLASSPATH/LD_LIBRARY_PATH/LD_LIBRARYN32_PATH
- # has components from /usr/java under an
- # alternate root, but java components are being taken from /usr/java.
- path_warn $1 $2
- fi
- fi
- fi
- }
-
- # Set up default variable values if not supplied by the user.
-
- PRG=`whence $0` >/dev/null 2>&1
- J_HOME=`/usr/bin/dirname $PRG`/..
- progname=`/usr/bin/basename $0`
-
-
- # The default ABI is n32, unless the SGI_ABI environment variable
- # indicates otherwise.
-
- if [[ $SGI_ABI = -32 ]]
- then
- export JAVA_N32=0
- elif [[ $SGI_ABI = -o32 ]]
- then
- export JAVA_N32=0
- else
- export JAVA_N32=1
- fi
-
- # The default THREADS_TYPE is "green_threads". To change the default change
- # the setting of the DEFAULT_THREADS_FLAG variable. The only valid values
- # of that variable are 'green' and 'native'.
- #
- # This introduces a dependency of this wrapper on the policy used to do builds.
- # e.g. the usage of the name "green_threads" here is dependent on the build
- # scripts which use the same name. Since this is somewhat analogous to the
- # wrapper already depending on the build scripts putting the executable in
- # a specific place (JAVA_HOME/bin/sgi), the new dependency does not
- # seem all that bad.
-
- DEFAULT_THREADS_FLAG=green
-
- if [[ ${THREADS_FLAG:-${DEFAULT_THREADS_FLAG}} = native ]] ; then
- THREADS_TYPE=native_threads
- else
- THREADS_TYPE=green_threads
- fi
- export THREADS_TYPE
- #echo "Using executables built for $THREADS_TYPE"
-
- #
- # If any combination of -32/-o32/-n32/-green/-native is at the beginning
- # of the argument list, override ABI and threads type based on that. Also,
- # remove them from $@, because they are arguments _only_ to this wrapper.
- # These are alternatives to setting SGI_ABI or THREADS_FLAG.
- #
- for a in "$@"; do
- case $a in
- -native)
- THREADS_TYPE=native_threads
- shift
- ;;
- -green)
- THREADS_TYPE=green_threads
- shift
- ;;
- -32)
- JAVA_N32=0
- shift
- ;;
- -o32)
- JAVA_N32=0
- shift
- ;;
- -n32)
- JAVA_N32=1
- shift
- ;;
- *)
- break
- ;;
- esac
- done
-
- if [ -z "$JAVA_HOME" ] ; then
- export JAVA_HOME
- JAVA_HOME=$J_HOME
- fi
-
- #
- # For some programs like appletviewer, it is important that "." not be
- # in the classpath by default (unless the user set the CLASSPATH
- # explicitly). Applications that fit in this list are ones that load
- # classes through a ClassLoader, where classes coming off . will end
- # up being system classes. For now we know of only appletviewer.
- #
- NO_DOT_LIST="appletviewer"
- DEFAULT_CLASSPATH="."
- for excluded in ${NO_DOT_LIST}; do
- if [ ${excluded} = ${progname} ]; then
- DEFAULT_CLASSPATH="";
- fi
- done
-
- CLASSPATH="${CLASSPATH:-${DEFAULT_CLASSPATH}}"
- check_path $CLASSPATH "CLASSPATH"
- COMM_CLASSPATH="$JAVA_HOME/classes:$JAVA_HOME/lib/rt.jar:$JAVA_HOME/lib/i18n.jar:$JAVA_HOME/lib/classes.zip"
-
- if [ -z "${CLASSPATH}" ] ; then
- CLASSPATH=$COMM_CLASSPATH
- else
- CLASSPATH="$CLASSPATH:$COMM_CLASSPATH"
- fi
-
- export CLASSPATH
-
- if [ $JAVA_N32 = 1 ]
- then
- check_path $LD_LIBRARYN32_PATH "LD_LIBRARYN32_PATH"
- if [ -z "$LD_LIBRARYN32_PATH" ]
- then
- if [ -z "$LD_LIBRARY_PATH" ]
- then
- LD_LIBRARYN32_PATH=$JAVA_HOME/lib32/sgi/$THREADS_TYPE
- else
- check_path $LD_LIBRARY_PATH "LD_LIBRARY_PATH"
- LD_LIBRARYN32_PATH="$JAVA_HOME/lib32/sgi/$THREADS_TYPE:$LD_LIBRARY_PATH"
- fi
- else
- LD_LIBRARYN32_PATH="$JAVA_HOME/lib32/sgi/$THREADS_TYPE:$LD_LIBRARYN32_PATH"
- fi
- export LD_LIBRARYN32_PATH
- prog=$JAVA_HOME/bin32/sgi/${THREADS_TYPE}/${progname}
- else
- check_path $LD_LIBRARY_PATH "LD_LIBRARY_PATH"
- if [ -z "$LD_LIBRARY_PATH" ]
- then
- LD_LIBRARY_PATH=$JAVA_HOME/lib/sgi/$THREADS_TYPE
- else
- LD_LIBRARY_PATH="$JAVA_HOME/lib/sgi/$THREADS_TYPE:$LD_LIBRARY_PATH"
- fi
- export LD_LIBRARY_PATH
- prog=$JAVA_HOME/bin/sgi/${THREADS_TYPE}/${progname}
- fi
-
- XFILESEARCHPATH="$JAVA_HOME/lib/locale/%L/%T/%N%S:$XFILESEARCHPATH"
- export XFILESEARCHPATH
-
- if [ -f $prog ]
- then
- exec $DEBUG_PROG $prog $opts "$@"
- else
- echo >&2 "$progname was not found in ${prog}"
- if [ $JAVA_N32 = 1 ] ; then
- ABI_STRING="n32"
- SUBSYSTEM_STRING_1="sw32"
- else
- ABI_STRING="o32"
- SUBSYSTEM_STRING_1="sw"
- fi
- if [ $THREADS_TYPE = "green_threads" ] ; then
- THREADS_STRING="green-threads"
- SUBSYSTEM_STRING_2="binaries"
- else
- THREADS_STRING="native-threads"
- SUBSYSTEM_STRING_2="native"
- fi
- echo >&2 "For $ABI_STRING $THREADS_STRING tools, install java_{eoe,dev}.$SUBSYSTEM_STRING_1.$SUBSYSTEM_STRING_2 subsystems"
- exit 1
- fi
-